/*
 * UserValidator.java
 *
 * Created on October 21, 2008, 5:55 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.vacuela.publishmx.domains.logic;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import org.vacuela.publishmx.domains.User;

/**
 *
 * @author nestor.carrasco
 */
public class UserValidator implements Validator {
    
    public boolean supports(Class clazz) {
        return User.class.isAssignableFrom(clazz);
    }
    
    public void validate(Object obj, Errors errors) {
        ValidationUtils.rejectIfEmpty(errors, "firstName", "FIRST_NAME_REQUIRED", "First name is required.");
        ValidationUtils.rejectIfEmpty(errors, "lastName", "LAST_NAME_REQUIRED", "Last name is required.");
      //  ValidationUtils.rejectIfEmpty(errors, "email", "EMAIL_REQUIRED", "Email address is required.");
        ValidationUtils.rejectIfEmpty(errors, "phone", "PHONE_REQUIRED", "Phone number is required.");
        ValidationUtils.rejectIfEmpty(errors, "address", "ADDRESS_REQUIRED", "Address is required.");
        ValidationUtils.rejectIfEmpty(errors, "role", "ROLE_REQUIRED", "Role is required.");
        
    }
    
}
